package tests;

import common.Utils;
import org.openqa.selenium.By;

public class LoginPage extends Utils {
    public static String url = "http://127.0.0.1:58080/sign-in.html";
    public LoginPage() {
        super(url);
    }

    /**
     * noRegister
     * 没有注册，返回注册页
     */
    public void noRegister() {
        driver.findElement(By.cssSelector("body > div.page.page-center > div > div > div:nth-child(1) > div > div.text-center.text-muted.mt-3 > a")).click();
        driver.findElement(By.cssSelector("#signUpForm > div > h2"));
        driver.navigate().back();
    }

    /**
     * loginSucceed
     * 登录成功
     */
    public void loginSucceed() {
        driver.findElement(By.cssSelector("#username")).sendKeys(userName);
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > h1 > a > img"));
        driver.navigate().refresh();
    }
}
